package service;

import bean.Users;
import dao.UsersDao;
import util.MD5Util;

public class UserService {
    public static void login(Users user){
        String pwdMD5= MD5Util.getMD5Str(user.getPwd());
        user.setPwd(pwdMD5);

        UsersDao userDao = new UsersDao();
        userDao.selectForLogin(user);
    }

    public static int register(Users users){
        UsersDao userDao = new UsersDao();
        users.setPwd(MD5Util.getMD5Str(users.getPwd()));
        if(userDao.isUserExists(users)){
            return 0;
        }
        if(!userDao.insertUser(users)){
            return -1;
        }
        return 1;
    }
}
